#include <iostream>
#include <vector>

using namespace std;

inline bool check_validity(int pos)
{
    return (pos <= 0 || pos >= 64) ? false : true;
}

const vector<int>* generate_vec(int pos)
{
    static vector<int> vec;

    if (!check_validity(pos))
    {
        cout << "Overflow !";
        return 0;
    }

    for (int ix = (int)vec.size(); ix < pos; ix++)
        vec.push_back((ix + 1) * (3 * ix + 2) / 2);

    return &vec;
}

void print_vec(int number, const string & title)
{
    const vector<int> *vec = generate_vec(number);
    if (!vec)
        return;

    cout << title << endl;

    for (int ix = 0; ix < number; ix++)
        cout << (*vec)[ix] << " ";
    cout << endl;

    cout << "Length of vector is " << (*vec).size() << endl;
}

int main()
{
    int size;
    char cmd;

    do
    {
        cout << "Please enter the series length: ";
        cin >> size;
        const string title = "Numberic Series";
        print_vec(size, title);
        cout << "Try Again ? (Y/N)" << endl;
        cin >> cmd;

    } while (cmd == 'Y' or cmd == 'y');
    
    return 0;
}